package homework4;

import java.io.Serializable;
import java.util.Objects;

/**
 * User 类的特征有：用户名、密码(字符串类型)。
 */
public class User implements Serializable {

	private static final long serialVersionUID = -6897368810454765306L;
	private String name;
	private String password;

	public User() {
	}

	public User(String name, String password) {
		setName(name);
		setPassword(password);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;
		User user = (User) o;
		return Objects.equals(name, user.name) && Objects.equals(password, user.password);
	}

	@Override
	public int hashCode() {
		return Objects.hash(name, password);
	}

	@Override
	public String toString() {
		return "User{" +
				"name='" + name + '\'' +
				", password='" + password + '\'' +
				'}';
	}
}
